# 指定基础镜像，这是分阶段构建的前期阶段
FROM java:8
# 定义环境变量
ARG proxyenv=prod
ENV proxyenv $proxyenv
# 创建工作目录
RUN mkdir -p /opt/proxy
RUN mkdir -p /opt/proxy/logs
RUN mkdir -p /opt/proxy/bin
RUN mkdir -p /opt/proxy/conf
RUN mkdir -p /opt/proxy/lib
RUN mkdir -p /opt/proxy/licenses
# 拷贝文件
COPY ./bin/* /opt/proxy/bin/
COPY ./conf/* /opt/proxy/conf/
COPY ./lib/* /opt/proxy/lib/
COPY ./licenses/* /opt/proxy/license/
COPY LICENSE /opt/proxy/
RUN cp /opt/proxy/conf/server.yaml.$proxyenv /opt/proxy/conf/server.yaml
RUN cp /opt/proxy/conf/config-sharding.yaml.$proxyenv /opt/proxy/conf/config-sharding.yaml
RUN cp /opt/proxy/conf/database.properties.$proxyenv /opt/proxy/conf/database.properties
RUN rm -rf /opt/proxy/conf/server.yaml.*
RUN rm -rf /opt/proxy/conf/config-sharding.yaml.*
#COPY ./conf/server-$proxyenv.yaml /opt/proxy/conf/server.yaml
#COPY ./conf/config-sharding-$proxyenv.yaml /opt/proxy/conf/config-sharding.yaml
RUN chmod +x /opt/proxy/bin/*.sh
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
# 自启动命令
ENTRYPOINT /opt/proxy/bin/start.sh && tail -f /opt/proxy/logs/stdout.log
